/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-07-31
 * Time: 22:26
 */
//https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&rp=1&ru=/activity/oj&qru=/ta/coding-interviews/question-ranking
//输入一棵二叉搜索树，将该二叉搜索树转换成一个排序的双向链表。
//要求不能创建任何新的结点，只能调整树中结点指针的指向。当转化完成以后，树中节点的左指针需要指向前驱，树中节点的右指针需要指向后继
public class Test {
    public static void main(String[] args) {
        TreeNode A1=new TreeNode(10);
        TreeNode A2=new TreeNode(6);
        TreeNode A3=new TreeNode(14);
        TreeNode A4=new TreeNode(4);
        TreeNode A5=new TreeNode(8);
        TreeNode A6=new TreeNode(12);
        TreeNode A7=new TreeNode(16);
        A1.left=A2;A1.right=A3;
        A2.left=A4;A2.right=A5;
        A3.left=A6;A3.right=A7;
        Fun fun=new Fun();
        TreeNode p=fun.Convert(A1);
        while(p!=null){
            System.out.println(p.val);
            p=p.right;
        }
    }
}
